package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallKeyword;
import org.apache.ibatis.jdbc.SQL;

public class HaogoumallKeywordSqlProvider {

    public String insertSelective(HaogoumallKeyword record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("haogoumall_keyword");
        
        if (record.getKeywordId() != null) {
            sql.VALUES("keyword_id", "#{keywordId,jdbcType=INTEGER}");
        }
        
        if (record.getKeyword() != null) {
            sql.VALUES("keyword", "#{keyword,jdbcType=VARCHAR}");
        }
        
        if (record.getKeywordUrl() != null) {
            sql.VALUES("keyword_url", "#{keywordUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getKeywordIsHot() != null) {
            sql.VALUES("keyword_is_hot", "#{keywordIsHot,jdbcType=BIT}");
        }
        
        if (record.getKeywordIsDefault() != null) {
            sql.VALUES("keyword_is_default", "#{keywordIsDefault,jdbcType=BIT}");
        }
        
        if (record.getKeywordSortOrder() != null) {
            sql.VALUES("keyword_sort_order", "#{keywordSortOrder,jdbcType=INTEGER}");
        }
        
        if (record.getKeywordAddTime() != null) {
            sql.VALUES("keyword_add_time", "#{keywordAddTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getKeywordUpdateTime() != null) {
            sql.VALUES("keyword_update_time", "#{keywordUpdateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getKeywordDeleted() != null) {
            sql.VALUES("keyword_deleted", "#{keywordDeleted,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(HaogoumallKeyword record) {
        SQL sql = new SQL();
        sql.UPDATE("haogoumall_keyword");
        
        if (record.getKeyword() != null) {
            sql.SET("keyword = #{keyword,jdbcType=VARCHAR}");
        }
        
        if (record.getKeywordUrl() != null) {
            sql.SET("keyword_url = #{keywordUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getKeywordIsHot() != null) {
            sql.SET("keyword_is_hot = #{keywordIsHot,jdbcType=BIT}");
        }
        
        if (record.getKeywordIsDefault() != null) {
            sql.SET("keyword_is_default = #{keywordIsDefault,jdbcType=BIT}");
        }
        
        if (record.getKeywordSortOrder() != null) {
            sql.SET("keyword_sort_order = #{keywordSortOrder,jdbcType=INTEGER}");
        }
        
        if (record.getKeywordAddTime() != null) {
            sql.SET("keyword_add_time = #{keywordAddTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getKeywordUpdateTime() != null) {
            sql.SET("keyword_update_time = #{keywordUpdateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getKeywordDeleted() != null) {
            sql.SET("keyword_deleted = #{keywordDeleted,jdbcType=BIT}");
        }
        
        sql.WHERE("keyword_id = #{keywordId,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}